<extend name="./base" />
<block name="pageContent">
    <link rel="stylesheet" href="{$Think.config.DOMAIN_URL}/Public/AdminTpl/css/s-settle.css">
    <div class="main-content">
        <!-- 头部面包屑导航条 -->
        <div class="breadcrumbs" id="breadcrumbs">
            <!--导航路径列表-->
            <ul class="breadcrumb no-margin-left">
                <li>
                    <a>管理后台</a>
                </li>
                <li class="action">
                    权限管理
                    <i class="fa fa-times ace-icon"></i>
                </li>
            </ul>
        </div>
        <!--页面容器-->
        <div class="page-content">
            <div class="nav-tab" style="position: relative">
                <ul class="nav-tab-title ">
                    <li class="nav-this">新增权限组</li>
                </ul>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <form class="form-horizontal s_input-bgcolor jsform" method="post" action="{$Think.config.DOMAIN_URL}/power/editGroup">
                        <input  name="id" class="form-control" type="hidden" value="{$selfInfo.id}">
                        <input  name="page" class="form-control" type="hidden" value="{$page}">

                        <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20">
                            <div class="form-group">
                                <label class="col-sm-3 control-label text-right no-padding-right" for="form-field-1-1">组名称： </label>

                                <div class="col-sm-8">
                                    <input type="text" id="form-field-1-1" placeholder="请输入组名称" class="form-control" name="name" datatype="*" value="{$selfInfo.name}">
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9 col-md-6 col-sm-12 col-xs-12 pad-b20 text-right">
                            <button type="submit" class="btn " style="width: 120px;    border-radius: 2rem; background: #0451d7!important;border: 1px solid #0451d7;margin-left: 20px;">提交</button>
                            <a href="{$Think.config.DOMAIN_URL}/power/groupList?p={$page}" class="btn " style="width: 120px;    border-radius: 2rem; background: #fff!important; border: 1px solid #999;;margin-left: 20px;color: #999!important">返回</a>
                        </div>
                        <div class="space"></div>
                        <div class="row" style="clear: both">
                            <span class="col-lg-1 col-md-1 col-sm-2 col-xs-2 text-right">选择权限： </span>
                            <div  class="col-lg-11 col-md-11 col-sm-10 col-xs-10 s-fh-auto">
                                <div class="row s_fh-headbg">
                                    <div class="col-lg-2 col-md-2 text-center">模块</div>
                                    <div class="col-lg-2 col-md-2  text-center">操作</div>
                                </div>
                                <volist name="menuArr" id="vo" key="k">
                                    <div class="row s_fhtable">
                                        <header class="s_fh-tabhead">
                                            <div class="col-lg-2 col-md-2"><img src="{$Think.config.DOMAIN_URL}/Public/AdminTpl/img/unfold_icon.png" alt="23" class="s-orain"/>{$platForm[$k]}</div>
                                        </header>
                                        <div class="row s_fh-showhide" style="margin: 0">
                                            <volist name="vo" id="v1">
                                                <div class="col-xs-12 s-fh-section">
                                                    <div class="col-xs-2 s-fh-left">
                                                        <input type="checkbox" value="{$v1.id}" name="menu[]" datatype="*" onchange="selectAll(this)" <in name="v1.id" value="$selfInfo.menu_ids">checked</in>/>{$v1.name}
                                                    </div>
                                                    <div class="col-xs-10 s-fh-right">
                                                        <volist name="v1.child" id="v2">
                                                            <span>
                                                                <input type="checkbox" value="{$v2.id}" name="menu[]" datatype="*" <in name="v2.id" value="$selfInfo.menu_ids">checked</in> onchange="changePselect(this)" />{$v2.name}
                                                            </span>
                                                        </volist>
                                                    </div>
                                                </div>
                                            </volist>
                                        </div>
                                    </div>
                                </volist>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
    <script>
        $(".s_fh-tabhead").on("click", function () {
            $(this).siblings(".s_fh-showhide").toggle();
            $(this).find("img").toggleClass("s-orain")
        })
        $(".jsform").Validform();

        //全选，全不选
        function selectAll(that){
            if($(that).is(':checked')){
                $(that).parent().siblings().find('input').each(function(){
                    $(this).prop("checked",true);
                });
            }else{
                $(that).parent().siblings().find('input').each(function(){
                    $(this).prop("checked",false);
                });
            }
        }

        //勾选父列表
        function changePselect(that){
            var selBool = false;
            $(that).parent().parent().find('input').each(function(){
                if($(this).is(':checked')){
                    selBool = true;
                }
            })
            if(selBool){
                $(that).parent().parent().siblings().find('input').prop("checked",true);
            }else{
                $(that).parent().parent().siblings().find('input').prop("checked",false);
            }
        }

    </script>
</block>